package be.florent.brol.client;

import be.credoc.common.gwt.actions.client.ActionServiceWrapper;
import be.credoc.common.gwt.actions.shared.service.ActionService;
import be.credoc.common.gwt.actions.shared.service.ActionServiceAsync;
import be.florent.brol.client.mvp.MyView;
import be.florent.brol.client.mvp.impl.MyViewImpl;

import com.google.gwt.core.client.GWT;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;

public class ClientFactoryImpl implements ClientFactory {

	private final EventBus eventBus = new SimpleEventBus();
	private final PlaceController placeController = new PlaceController(eventBus);
	private final ActionServiceWrapper actionServiceWrapper;
	
	// Views
	MyView myView = new MyViewImpl();
	
	public ClientFactoryImpl() {
		ActionServiceAsync as = GWT.create(ActionService.class);
		((ServiceDefTarget)as).setServiceEntryPoint("service/action");
		actionServiceWrapper = new ActionServiceWrapper(as);
	}
	
	@Override
	public EventBus getEventBus() {
		return eventBus;
	}

	@Override
	public PlaceController getPlaceController() {
		return placeController;
	}

	@Override
	public ActionServiceWrapper getActionServiceWrapper() {
		return actionServiceWrapper;
	}

	@Override
	public MyView getMyView() {
		return myView;
	}

}
